package com.example.smartmedicalsystem.entity;
import com.example.smartmedicalsystem.DayOfWeekSerializer;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.*;

import javax.persistence.*;

import java.time.DayOfWeek;
import java.time.LocalDate;

@Entity
@Table(name = "schedules")
@Getter @Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
public class Schedule {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Column(name = "date", nullable = false)  // 确保非空约束
    private LocalDate date;

    // 保持原有字段


    @JsonSerialize(using = DayOfWeekSerializer.DayOfWeekSerializerImpl.class) // 序列化规则
    @JsonDeserialize(using = DayOfWeekSerializer.DayOfWeekDeserializer.class) // 反序列化规则
    @Enumerated(EnumType.STRING) // 确保数据库存储字符串格式（如 "MONDAY"）
    @Column(name = "day_of_week", nullable = false)
    private DayOfWeek dayOfWeek;
    @Column(name = "time_slot", nullable = false)
    private String timeSlot;

    @ManyToOne
    @JoinColumn(name = "doctor_id", nullable = false)
    private Doctor doctor;



}
